move cache type -> icon recognition into common code.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 20 Feb 2003 15:44:05 +0000 (15:44 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 20 Feb 2003 15:44:05 +0000 (15:44 +0000)
gpsbabel/defs.h
gpsbabel/magproto.c
gpsbabel/util.c

index 883611df6d53ae9762fd541504842c93e48fd014..c53e5b3fb1206fed0c5e06971f6c098cb3556ab7 100644 (file)
@@ -247,7 +247,10 @@ typedef struct ff_vecs {
 typedef struct style_vecs {
        const char *name;
        const char *style_buf;
+       const char *desc;
+       const char *ext;
 } style_vecs_t;
+extern style_vecs_t style_list[];
 
 typedef struct filter_vecs {
        filter_init f_init;
@@ -318,6 +321,7 @@ int case_ignore_strcmp(const char *s1, const char *s2);
 
 void rtrim(char *s);
 signed int get_tz_offset(void);
+const char *get_cache_icon(const waypoint *waypointp);
 
 /*
  * PalmOS records like fixed-point numbers, which should be rounded
index 8b16a7922f1e4904733d779c73e636c4d771a73c..4d06e9eaf2dae4d1657b3477d6f82d2df7fa5897 100644 (file)
@@ -1083,25 +1083,10 @@ mag_waypt_pr(const waypoint *waypointp)
                icon_token = mag_find_token_from_descr(waypointp->icon_descr);
        }
 
-       /*
-        * For icons, type overwrites container.  So a multi-micro will 
-        * get the icons for "multi".
-        */
-       switch (waypointp->gc_data.container) {
-               case gc_micro: 
-                       icon_token = mag_find_token_from_descr("Micro-Cache");
-                       break;
-       }
-       switch (waypointp->gc_data.type) {
-               case gt_virtual:
-                       icon_token = mag_find_token_from_descr("Virtual cache");
-                       break;
-               case gt_multi:
-                       icon_token = mag_find_token_from_descr("Multi-Cache");
-                       break;
-               default:
-                       break;
+       if (get_cache_icon(waypointp)) {
+               icon_token = mag_find_token_from_descr(get_cache_icon(waypointp));
        }
+
        isrc = waypointp->notes ? waypointp->notes : waypointp->description;
        owpt = global_opts.synthesize_shortnames ?
                         mkshort(mkshort_handle, isrc) : waypointp->shortname,
index 5206a80ebea533ce9c438e8e6ed537130ce0f850..ab927acedeac4d682c73901dd019a3ee91f241d1 100644 (file)
@@ -342,3 +342,33 @@ get_tz_offset(void)
                return (signed int) difftime(now, later);
        }
 }
+
+/*
+ * Return a pointer to a constant string that is suitable for icon lookup
+ * based on geocache attributes.   The strings used are those present in 
+ * a GPX file from geocaching.com.  Thus we sort of make all the other 
+ * formats do lookups based on these strings.
+ */
+const char *
+get_cache_icon(const waypoint *waypointp)
+{
+       /*
+        * For icons, type overwrites container.  So a multi-micro will 
+        * get the icons for "multi".
+        */
+       switch (waypointp->gc_data.container) {
+               case gc_micro: 
+                       return "Micro-Cache";
+                       break;
+       }
+       switch (waypointp->gc_data.type) {
+               case gt_virtual:
+                       return "Virtual cache";
+               case gt_multi:
+                       return "Multi-Cache";
+                       break;
+               default:
+                       break;
+       }
+       return NULL;
+}